
var commonService = require('../../services/common.js');
var MusicService = require('../../services/music');
var util = require('../../utils/util.js')

var app = getApp();
Page({
  data: {
    imgUrl:'',
    id: 0,
    logs: [],
    songList:[],
    dissname:'',
    listBgColor: '',
    desc:'',
    tags:[]
  },
  onLoad: function () {
    var selft = this;
    var id = app.globalData.hotMusicId;
    var imgUrl = app.globalData.mainImg;  
    this.setData({
      id: id
    });
    console.log(imgUrl);
    MusicService.getHotMusicInfo(id, this.getMusicInfoCallback);
  
  },
  getMusicInfoCallback: function (data) {
    var self= this;
    if(data.code == 0) {
      var cdlist = data.cdlist;
      if(cdlist && cdlist.length) {
        var hotMusicInfo = cdlist[0];
        var imgUrl =hotMusicInfo.logo;
        this.setData({
          dissname:hotMusicInfo.hotMusicInfo,
          songList: hotMusicInfo.songlist,
          imgUrl: hotMusicInfo.logo,
          desc: hotMusicInfo.desc,
          tags: hotMusicInfo.tags
        });
        commonService.getBodyBgColor(imgUrl, this.setListBgColor)
      }
    }else {

    }
  },
  setListBgColor: function (color) {
    var a = util.dealColor(color);
    this.setData({
      listBgColor: a
    });
  }
})